const execa = require('execa')
function getGitBranch() {
  const res = execa.commandSync('git rev-parse --abbrev-ref HEAD')
  return res.stdout
}
const branch_name = getGitBranch()
module.exports = {
  rules: {
    'commit-rule': [2, 'always']
  },
  plugins: [
    {
      rules: {
        'commit-rule': ({ raw }) => {
          return [
            new RegExp(`^\\[v3-${branch_name}\\]\\s.+`, 'g').test(raw),
            `commit备注信息格式错误,格式为 [v3-${branch_name}] 提交信息`
          ]
        }
      }
    }
  ]
}
